/********************************************************************************
 * Copyright (c)2016-2020, ShenZhen WanJiaAn Technology CO.,LTD.
 * All Rights Reserved.
 *
 * File Name     : Net.h
 * Author        : joki.zhu
 * Date          : 2019-10-24
 *
 * Record        :
 * 1.Date        : 2019-10-24
 *   Author      : joki.zhu
 *   Modification: Created file
 ********************************************************************************/

#ifndef __NET_H__
#define __NET_H__

#include "sys/types.h"
#include "sys/socket.h"
#include "netdb.h"

#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */

typedef struct {
    unsigned char ip[16];
    unsigned char netmask[16];
    unsigned char gateway[16];
    unsigned char mac[24];
    unsigned dns1[16];
    unsigned dns2[16];
}NET_ATTR_INFO_S;


/****************************************** liteos begin****************************************/
int netliteos_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
void netlieos_freeaddrinfo(struct addrinfo *res);
struct hostent *netliteos_gethostbyname(const char *name);

int NetLiteosGetAddrInfo(char *inAddr, char *outIp);
int NetIperf(int argc, char *argv[]);
int NetSetDns(char *dns1, char *dns2);
int NetGetDns(char *dns1, char *dns2);

/****************************************** liteos end****************************************/


/****************************************** linux begin****************************************/
int NetGetAttrInfo(char *ifname, NET_ATTR_INFO_S *pstNetAttrInfo);
int NetSetAttrInfo(char *ifname, NET_ATTR_INFO_S stNetAttrInfo);

/**
 * 网络ping
 *
 * @param[in] hostname 主机名 域名/IP
 * @param[in] cout 发送ping包个数
 * @param[in] timeoutMs 每个ping包等待接收的超时毫秒数
 *
 * @retval 0 网络异常
 * @retval 1 网络正常
 *
 * @attention 无
 */
int NetPing(char *hostname, int count, int timeoutMs);

/****************************************** linux end****************************************/



#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */


#endif /* __NET_H__ */
